///////////////////////////////////////////////////////////////
// Copyright(c) ephiroth
// 
// FileName : formula_hunh.c
// Creator  : ephiroth
// E-Mail   : ephiroth@gmail.com
// Date     : 2009-05-06
// Comment  : 
//
///////////////////////////////////////////////////////////////
#include "comm.h"

static int func_hunh (int index , U8 data [])
{
	int m, op1,l,n,ret;
	m = trim_char(data[1],10,100);
	op1 = trim_char(data[3],1,3);
	l = trim_char (data[4],1,10);
	n = trim_char (data[5],1,10);
	if ( index == 0 )
		ret = m;
	else
	{
	if ( op1 == 1 )
		ret = func_hunh(index -1 , data ) + l*(index*index)/2 + n*(index *(index+2))/2;
	else if (op1 == 2)
		ret = func_hunh(index - 1 ,data) + l*(index *index)/2 - n*(index*(index+2))/2;
	else if (op1 == 3 ) 
		ret = (func_hunh(index - 1 , data) + l* (index*index)/2 ) *n*(index*(index+2))/2;
	}	
	return ret ;
		
}

static void help_hunh(U8 * data)
{
	int l, n;
	l = trim_char (data[4],1,10);
	n = trim_char (data[5],1,10);
	printf("[后项数为前项数加一二次数列再于另一二次数列做差或乘运算]:%d\t%d\n",l,n);
}

formula formula_hunh = {
	"hunh",
	ft_normal,
	5,
	func_hunh ,
	help_hunh,
	
};


